using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Tdoctypes Test Class
  /// </summary>
  [TestClass]
  public class TestTdoctypes
  {
    #region Class Variables
    private CdoPrms<DOTdoctypes>		m_Tdoctypes;
    private CdoPrmsList<DOTdoctypes>	m_AllTdoctypes;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestTdoctypes()
    {
      // Create the data objects
      this.m_Tdoctypes	= new CdoPrms<DOTdoctypes>();
      this.m_AllTdoctypes	= new CdoPrmsList<DOTdoctypes>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Tdoctypes data objects
    /// </summary>
    [TestMethod]
    public void TdoctypesRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllTdoctypes.DataObject = new DOTdoctypes();
      this.m_AllTdoctypes.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllTdoctypes.PerformAction())
      {
        // Assert the errors
        if (this.m_AllTdoctypes.Errors.Count > 0) { Assert.Fail(this.m_AllTdoctypes.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Tdoctypes
    /// </summary>
    [TestMethod]
    public void TdoctypesCreate()
    {
      // Set up the data object for creation
      this.m_Tdoctypes.DataObject.mandatory = false;
      this.m_Tdoctypes.DataObject.useqc = false;
      this.m_Tdoctypes.DataObject.initreq = 10;
      this.m_Tdoctypes.DataObject.dispseq = 10;
      this.m_Tdoctypes.DataObject.tooltip = "Test tooltip";
      this.m_Tdoctypes.DataObject.barcode = 'b';
      this.m_Tdoctypes.DataObject.istd = false;
      this.m_Tdoctypes.DataObject.ismb = false;
      this.m_Tdoctypes.DataObject.isrelease = false;
      this.m_Tdoctypes.DataObject.containername = "Test containername";
      this.m_Tdoctypes.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Tdoctypes.PerformAction())
      {
        // Assert the errors
        if (this.m_Tdoctypes.Errors.Count > 0) { Assert.Fail(this.m_Tdoctypes.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Tdoctypes
    /// </summary>
    [TestMethod]
    public void TdoctypesRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Tdoctypes.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Tdoctypes.DataObject.doctype = 'b';
      }

      // Set up the data object action for retrieval
      this.m_Tdoctypes.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Tdoctypes.PerformAction())
      {
        // Assert the errors
        if (this.m_Tdoctypes.Errors.Count > 0) { Assert.Fail(this.m_Tdoctypes.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
